home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / Debconf / FrontEnd / ScreenSize.pm < prev    next >
Encoding:
Perl POD Document  |  2009-03-24  |  881 b   |  55 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::FrontEnd::ScreenSize;
  6. use strict;
  7. use Debconf::Gettext;
  8. use base qw(Debconf::FrontEnd);
  9.  
  10.  
  11. sub init {
  12.     my $this=shift;
  13.  
  14.     $this->SUPER::init(@_);
  15.  
  16.     $this->resize; # Get current screen size.
  17.     $SIG{WINCH}=sub {
  18.         if (defined $this) {
  19.             $this->resize;
  20.         }
  21.     };
  22. }
  23.  
  24.  
  25. sub resize {
  26.     my $this=shift;
  27.  
  28.     if (exists $ENV{LINES}) {
  29.         $this->screenheight($ENV{'LINES'});
  30.         $this->screenheight_guessed(0);
  31.     }
  32.     else {
  33.         my ($rows)=`stty -a 2>/dev/null` =~ m/rows (\d+)/s;
  34.         if ($rows) {
  35.             $this->screenheight($rows);
  36.             $this->screenheight_guessed(0);
  37.         }
  38.         else {
  39.             $this->screenheight(25);
  40.             $this->screenheight_guessed(1);
  41.         }
  42.     }
  43.  
  44.     if (exists $ENV{COLUMNS}) {
  45.         $this->screenwidth($ENV{'COLUMNS'});
  46.     }
  47.     else {
  48.         my ($cols)=`stty -a 2>/dev/null` =~ m/columns (\d+)/s;
  49.         $this->screenwidth($cols || 80);
  50.     }
  51. }
  52.  
  53.  
  54. 1
  55.